using Microsoft.Extensions.DependencyInjection;
using UniversalAdminSystem.Domian;
using UniversalAdminSystem.Domian.PermissionManagement.Services;
using UniversalAdminSystem.Domian.FileStorage.Services;
using UniversalAdminSystem.Domian.PermissionManagement.Interfaces;

namespace UniversalAdminSystem.Infrastructure.DependencyInject;

public static class AddDomainService
{
    public static IServiceCollection AddDomain(this IServiceCollection services)
    {
        // 自动发现并注册领域服务
        var list = DomainServices.DiscoverServices();
        foreach (var (serviceType, implementationType) in list)
        {
            services.AddScoped(serviceType, implementationType);
        }

        // 手动注册领域服务（确保所有领域服务都被注册）
        services.AddScoped<IAssignPermissionDomainService, AssignPermissionDomainService>();
        services.AddScoped<FileDomainService>();

        return services;
    }
}